home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / ashe-1.1 / xfile.c < prev    next >
C/C++ Source or Header  |  1995-05-15  |  67KB  |  2,025 lines

  1. /*
  2.  * 
  3.  * 
  4.  * xfile.c - (c) 1994 Copyright by John R. Punin
  5.  *
  6.  * ASHE
  7.  *
  8.  * This file has the routines to create the menus and the 
  9.  *
  10.  * Options of the File  and Edit Menu
  11.  * 
  12.  * John R. Punin      Feb - 26 - 1994
  13.  * 
  14.  */
  15. #include "xhtml.h"
  16. #include "xfile.h"
  17. #include "xheader.h"
  18. #include "xstyles.h"
  19. #include "xviewer.h"
  20. #include "xform.h"
  21.  
  22. extern MenuItem form_menu[];
  23.  
  24. /* 
  25.    NAME : CreateMenuBar
  26.    PARAMETERS : Widget parent
  27.                 Parent of the Widget Menubar in this case main_widget
  28.    RETURN : Widget Menubar
  29.    DESCRIPTION : This function creates the menubar widget at the top
  30.                  of the main window and also creates each item of
  31.          the menus.
  32.          Menus are : File, Edit, HTML, Style, Lists and Forms
  33.          File Items : New, Open, Save, Insert and Quit
  34.          Edit Items : Cut, Copy, Paste, Delete and Undo
  35.          HTML Items : Title, Header, Paragraph, Link, Reference
  36.                       and Image
  37.          Style Items : Code, Cyte, Blockquote, Address, 
  38.                        Bold, Italic and Underline
  39.          Lists Items : Definition, Term,
  40.                        Unordered, Ordered and Item
  41.    
  42. */
  43. Widget 
  44. CreateMenuBar(Widget parent,HTMLED *he)
  45. {
  46.    XmString file,open,open_acc,save,save_acc,quit,quit_acc,save_as,
  47.             insert,insert_acc,new,new_acc,frame,close_frame,prnt,export,
  48.             frame_acc,close_frame_acc,save_as_acc,prnt_acc,
  49.             edit,cut,copy,clears,paste,undos,hor_rule,
  50.             cut_acc,copy_acc,clear_acc,paste_acc,undo_acc,fonts,
  51.             title,title_acc,address,address_acc,
  52.             paragraph,parag_acc,comments,document,line_break,
  53.             header,header_acc,help,html,reload,reload_acc,
  54.             linker,linker_acc,reference,refer_acc,
  55.             figure,figure_acc,pre,pre_acc,
  56.             comments_acc,hor_rule_acc,
  57.             styles,code,cite,block,bold,italic,under,
  58.             ttwriter,emphasis,strong,characters,
  59.             code_acc,cite_acc,block_acc,bold_acc,italic_acc,under_acc,
  60.             emphasis_acc,strong_acc,ttwriter_acc,
  61.             lists,definition,term,unorder,order,item,
  62.             definition_acc,term_acc,unorder_acc,order_acc,item_acc;
  63.    XmString html_one,head_two,body_three;
  64.    XmString html_one_acc,head_two_acc,body_three_acc;
  65.    XmString dummy_acc=XmStringCreateSimple("");
  66.    Widget button_doc,menu_fonts,button_fonts;
  67.  
  68.    Widget menubar,Help,menu_doc,menu_file,menu_html;
  69.    Widget editwidget;
  70.  
  71.    /* Create a simple MenuBar that contains the following items */
  72.    file = XmStringCreateSimple("File");
  73.    edit = XmStringCreateSimple("Edit");
  74.    html = XmStringCreateSimple("HTML");
  75.    styles = XmStringCreateSimple("Styles");
  76.    lists =XmStringCreateSimple("Lists");
  77.    help = XmStringCreateSimple("Help");
  78.    characters= XmStringCreateSimple("Characters");
  79.    menubar = XmVaCreateSimpleMenuBar(parent,"menubar",
  80.                      XmVaCASCADEBUTTON,file,'F',
  81.                      XmVaCASCADEBUTTON,edit,'E',
  82.                      XmVaCASCADEBUTTON,html,'M',
  83.                      XmVaCASCADEBUTTON,styles,'y',
  84.                      XmVaCASCADEBUTTON,lists,'L',
  85.                      XmVaCASCADEBUTTON,characters,'\0',
  86.                      XmVaCASCADEBUTTON,help,'H',
  87.                      NULL);
  88.  
  89.    XmStringFree(file);
  90.    XmStringFree(edit);
  91.    XmStringFree(help);
  92.    XmStringFree(styles);
  93.    XmStringFree(html);
  94.    XmStringFree(lists);
  95.    XmStringFree(characters);
  96.    
  97.  
  98.    /* tell the MenuBar that this is the help widget*/
  99.    Help = XtNameToWidget(menubar,"button_6");
  100.    XtVaSetValues(menubar,XmNmenuHelpWidget,Help,NULL);
  101.    BuildHelpMenu(menubar,he);
  102.  
  103.    /* Create Form menu */
  104.    
  105.    BuildPulldownMenu(menubar,"Forms",'r', False, form_menu,he);
  106.  
  107.    /* First menu is the File menu */
  108.  
  109.    open = XmStringCreateSimple("Open...");
  110.    open_acc = XmStringCreateSimple("Meta-o");
  111.    save = XmStringCreateSimple("Save");
  112.    save_acc = XmStringCreateSimple("Meta-s");
  113.    save_as = XmStringCreateSimple("Save as...");
  114.    save_as_acc = XmStringCreateSimple("Meta-a");
  115.    insert = XmStringCreateSimple("Insert...");
  116.    insert_acc = XmStringCreateSimple("Meta-I");
  117.    new = XmStringCreateSimple("New");
  118.    new_acc = XmStringCreateSimple("Meta-n");
  119.    export = XmStringCreateSimple("Export as...");
  120.    prnt = XmStringCreateSimple("Print...");
  121.    prnt_acc = XmStringCreateSimple("Meta-P");
  122.    reload = XmStringCreateSimple("Reload");
  123.    reload_acc = XmStringCreateSimple("Ctrl-r");
  124.    frame = XmStringCreateSimple("New Frame");
  125.    frame_acc = XmStringCreateSimple("");
  126.    close_frame = XmStringCreateSimple("Close Frame");
  127.    close_frame_acc = XmStringCreateSimple("Alt-f-c");
  128.    quit = XmStringCreateSimple("Quit...");
  129.    quit_acc = XmStringCreateSimple("Meta-q");
  130.    menu_file = XmVaCreateSimplePulldownMenu(menubar,"file_menu",
  131.                         0,(XtCallbackProc)file_cb,
  132.            XmVaPUSHBUTTON, new, 'N',"Meta<Key>n",new_acc,
  133.            XmVaPUSHBUTTON, open, 'O',"Meta<Key>o" ,open_acc,
  134.            XmVaPUSHBUTTON, save, 'S', "Meta<Key>s",save_acc,
  135.            XmVaPUSHBUTTON, save_as, 'a',"Meta<Key>a",save_as_acc,
  136.            XmVaPUSHBUTTON, insert, 'I',"Meta Shift<Key>i",insert_acc,
  137.                    XmVaPUSHBUTTON, export, 'E',"",dummy_acc,
  138.            XmVaPUSHBUTTON, reload, 'R',"Ctrl<Key>r",reload_acc,
  139.            XmVaPUSHBUTTON, prnt, 'P',"Meta Shift <Key>p",prnt_acc,
  140.            /* XmVaSEPARATOR,*/
  141.            XmVaPUSHBUTTON, frame,'F',"",dummy_acc,
  142.            XmVaPUSHBUTTON, close_frame,'C',"",dummy_acc,
  143.            /* XmVaSEPARATOR,*/
  144.            XmVaPUSHBUTTON, quit, 'Q',"Meta<Key>q",quit_acc,
  145.            XmNuserData,he,
  146.        NULL);
  147.    XmStringFree(export);
  148.    XmStringFree(new);XmStringFree(new_acc);
  149.    XmStringFree(open);XmStringFree(open_acc);
  150.    XmStringFree(save);XmStringFree(save_acc);
  151.    XmStringFree(insert);XmStringFree(insert_acc);
  152.    XmStringFree(quit);XmStringFree(quit_acc);
  153.    XmStringFree(save_as);XmStringFree(save_as_acc);
  154.    XmStringFree(frame);XmStringFree(frame_acc);
  155.    XmStringFree(prnt);XmStringFree(prnt_acc);
  156.    XmStringFree(reload);XmStringFree(reload_acc);
  157.    XmStringFree(close_frame);XmStringFree(close_frame_acc);
  158.    
  159.    /* Second menu is the EDIT menu */
  160.    cut = XmStringCreateSimple("Cut");
  161.    cut_acc = XmStringCreateSimple("Ctrl-Meta-x");
  162.    copy = XmStringCreateSimple("Copy");
  163.    copy_acc = XmStringCreateSimple("Ctrl-Meta-c");
  164.    clears = XmStringCreateSimple("Delete");
  165.    clear_acc = XmStringCreateSimple("Ctrl-Meta-d");
  166.    paste = XmStringCreateSimple("Paste");
  167.    paste_acc = XmStringCreateSimple("Ctrl-Meta-p");
  168.    undos = XmStringCreateSimple("Undo");
  169.    undo_acc = XmStringCreateSimple("Ctrl-Meta-u");
  170.    fonts = XmStringCreateSimple("Change Fonts");
  171.  
  172.    editwidget = XmVaCreateSimplePulldownMenu(menubar,"edit_menu",
  173.                          1,(XtCallbackProc)cut_paste,
  174.            XmVaPUSHBUTTON, cut, 'C',"",dummy_acc,
  175.            XmVaPUSHBUTTON, copy, 'o',"",dummy_acc,
  176.            XmVaPUSHBUTTON, paste, 'P',"Ctrl Meta <Key>p",paste_acc,
  177.            /*XmVaSEPARATOR,*/
  178.            XmVaPUSHBUTTON, clears, 'D',"Ctrl Meta <Key>d",clear_acc,
  179.            /*XmVaSEPARATOR,*/
  180.            XmVaPUSHBUTTON, undos, 'U',"Ctrl Meta <Key>u",undo_acc,
  181.            /*XmVaSEPARATOR,*/
  182.            XmVaCASCADEBUTTON,fonts,'F',
  183.            XmNuserData,he,
  184.            NULL);
  185.    
  186.    XtSetSensitive(XtNameToWidget(editwidget,"button_0"),False);
  187.    XtSetSensitive(XtNameToWidget(editwidget,"button_1"),False);
  188.    XtSetSensitive(XtNameToWidget(editwidget,"button_2"),False);
  189.    he->editwidget = editwidget;
  190.    
  191.    XmStringFree(cut);   XmStringFree(cut_acc);
  192.    XmStringFree(copy);   XmStringFree(copy_acc);
  193.    XmStringFree(clears);   XmStringFree(clear_acc);
  194.    XmStringFree(paste);   XmStringFree(paste_acc);
  195.    XmStringFree(undos);   XmStringFree(undo_acc);
  196.  
  197.    button_fonts = NULL;
  198.    button_fonts = XtNameToWidget(editwidget,"button_5");
  199.    {
  200.       XmString tregular = XmStringCreateSimple("Times Regular");
  201.       XmString tsmall = XmStringCreateSimple("Times Small");
  202.       XmString tlarge = XmStringCreateSimple("Times Large");
  203.       XmString hregular = XmStringCreateSimple("Helvetica Regular");
  204.       XmString hsmall = XmStringCreateSimple("HelvelticaTimes Small");
  205.       XmString hlarge = XmStringCreateSimple("Helvetica Large");
  206.       XmString ncregular = XmStringCreateSimple("New Century Regular");
  207.       XmString ncsmall = XmStringCreateSimple("New Century Small");
  208.       XmString nclarge = XmStringCreateSimple("New Century Large");
  209.       XmString lregular = XmStringCreateSimple("Lucida Bright Regular");
  210.       XmString lsmall = XmStringCreateSimple("Lucida Bright Small");
  211.       XmString llarge = XmStringCreateSimple("Lucida Bright Large");
  212.  
  213.       menu_fonts = XmVaCreateSimplePulldownMenu(editwidget,"menu_fonts",
  214.          5,/* button fonts */(XtCallbackProc)routines_fonts,
  215.          XmVaPUSHBUTTON,tregular, 'T',"",dummy_acc,
  216.          XmVaPUSHBUTTON,tsmall , 'S',"",dummy_acc,
  217.          XmVaPUSHBUTTON,tlarge, 'L',"",dummy_acc,        
  218.          /*XmVaSEPARATOR,*/
  219.          XmVaPUSHBUTTON,hregular, 'H',"",dummy_acc,
  220.          XmVaPUSHBUTTON,hsmall , 'e',"",dummy_acc,
  221.          XmVaPUSHBUTTON,hlarge, 'v',"",dummy_acc,
  222.          /*XmVaSEPARATOR,*/
  223.          XmVaPUSHBUTTON,ncregular, 'N',"",dummy_acc,
  224.          XmVaPUSHBUTTON,ncsmall , 'w',"",dummy_acc,
  225.          XmVaPUSHBUTTON,nclarge, 'C',"",dummy_acc,
  226.          /*XmVaSEPARATOR,*/
  227.          XmVaPUSHBUTTON,lregular, 'L',"",dummy_acc,
  228.          XmVaPUSHBUTTON,lsmall , 'u',"",dummy_acc,
  229.          XmVaPUSHBUTTON,llarge, 'i',"",dummy_acc,
  230.                  XmNuserData,he,                       
  231.          NULL);
  232.    if(button_fonts)
  233.       XtVaSetValues(button_fonts,XmNsubMenuId,menu_fonts,NULL);
  234.  
  235.    XmStringFree(tsmall); XmStringFree(tregular);XmStringFree(tlarge);
  236.    XmStringFree(ncsmall); XmStringFree(ncregular);XmStringFree(nclarge);
  237.    XmStringFree(hsmall); XmStringFree(hregular);XmStringFree(hlarge);
  238.    XmStringFree(lsmall); XmStringFree(lregular);XmStringFree(llarge);
  239.  
  240.    XtManageChild(menu_fonts);;
  241.    }
  242.  
  243.    /* Third menu is the HTML menu */
  244.    title = XmStringCreateSimple("Title...");
  245.    title_acc = XmStringCreateSimple("Meta-t");
  246.    header = XmStringCreateSimple("Header...");
  247.    header_acc = XmStringCreateSimple("");
  248.    paragraph = XmStringCreateSimple("Paragraph");
  249.    parag_acc = XmStringCreateSimple("Meta-p");
  250.    line_break = XmStringCreateSimple("Line Break");
  251.    hor_rule= XmStringCreateSimple("Horiz. rule");
  252.    hor_rule_acc= XmStringCreateSimple("Meta-H");
  253.    comments= XmStringCreateSimple("Commentary...");
  254.    comments_acc= XmStringCreateSimple("Meta-C");
  255.    pre = XmStringCreateSimple("Preformat...");
  256.    pre_acc = XmStringCreateSimple("Meta-F");
  257.    linker =XmStringCreateSimple("Hyperlink...");
  258.    linker_acc = XmStringCreateSimple("Meta-L");
  259.    reference =XmStringCreateSimple("Reference...");
  260.    refer_acc = XmStringCreateSimple("Meta-N");
  261.    figure =XmStringCreateSimple("Image...");
  262.    figure_acc = XmStringCreateSimple("Meta-G");
  263.    document =XmStringCreateSimple("Document");
  264.    menu_html=XmVaCreateSimplePulldownMenu(menubar,"title_menu",2,
  265.                       (XtCallbackProc)routines_html,
  266.            XmVaPUSHBUTTON, title, 'T',"Meta<Key>t",title_acc,
  267.            XmVaPUSHBUTTON, header, 'H',"",dummy_acc,
  268.            XmVaPUSHBUTTON, paragraph, 'P',"Meta<Key>p",parag_acc,
  269.            XmVaPUSHBUTTON, line_break, 'b',"",dummy_acc,
  270.          XmVaPUSHBUTTON, hor_rule, 'r',"Meta Shift<Key>h",hor_rule_acc,
  271.            XmVaPUSHBUTTON, pre, 'f',"Meta Shift<Key>f",pre_acc,
  272.         XmVaPUSHBUTTON, comments, 'c',"Meta Shift<Key>c",comments_acc,
  273.            /*XmVaSEPARATOR,*/
  274.                XmVaPUSHBUTTON, linker, 'l',"Meta Shift<Key>l",linker_acc,
  275.            XmVaPUSHBUTTON, reference, 'n',"Meta Shift<Key>n",refer_acc,
  276.                    XmVaPUSHBUTTON, figure, 'I',"Meta Shift<Key>g",figure_acc,
  277.                    XmVaCASCADEBUTTON, document, 'D',
  278.            XmNuserData,he,
  279.        NULL);
  280.  
  281.    button_doc = NULL;
  282.    button_doc = XtNameToWidget(menu_html,"button_10");
  283.  
  284.    XmStringFree(title);XmStringFree(title_acc);
  285.    XmStringFree(header);XmStringFree(header_acc);
  286.    XmStringFree(paragraph); XmStringFree(parag_acc);
  287.    XmStringFree(line_break);
  288.    XmStringFree(pre); XmStringFree(pre_acc);
  289.    XmStringFree(linker);XmStringFree(linker_acc);
  290.    XmStringFree(reference);XmStringFree(refer_acc);
  291.    XmStringFree(figure);XmStringFree(figure_acc);
  292.    XmStringFree(comments);  XmStringFree(comments_acc); XmStringFree(document);
  293.    XmStringFree(hor_rule); XmStringFree(hor_rule_acc);
  294.    XtManageChild(menu_html);
  295.  
  296.    /* create menu for document  button */
  297.  
  298.    html_one = XmStringCreateSimple("HTML...");
  299.    html_one_acc = XmStringCreateSimple("Alt-t-d-h");
  300.    head_two = XmStringCreateSimple("Head...");
  301.    head_two_acc = XmStringCreateSimple("Alt-t-d-e");
  302.    body_three = XmStringCreateSimple("Body...");
  303.    body_three_acc = XmStringCreateSimple("Alt-t-d-b");
  304.  
  305.    menu_doc = XmVaCreateSimplePulldownMenu(menu_html,"menu_doc",
  306.          10,/* button document */(XtCallbackProc)routines_styles,
  307.          XmVaPUSHBUTTON,html_one , 'H',"",dummy_acc,
  308.          XmVaPUSHBUTTON,head_two, 'e',"",dummy_acc,
  309.          XmVaPUSHBUTTON, body_three, 'B',"",dummy_acc,
  310.                  XmNuserData,he,                       
  311.          NULL);
  312.    if(button_doc)
  313.       XtVaSetValues(button_doc,XmNsubMenuId,menu_doc,NULL);
  314.  
  315.    XmStringFree(html_one ); XmStringFree(head_two);XmStringFree(body_three);
  316.    XmStringFree(html_one_acc ); XmStringFree(head_two_acc);
  317.    XmStringFree(body_three_acc);
  318.    XtManageChild(menu_doc);
  319.  
  320.    /* Fourth menu is the Style menu */
  321.    code = XmStringCreateSimple("Code...");
  322.    code_acc = XmStringCreateSimple("Alt-s-c");
  323.    cite = XmStringCreateSimple("Cite...");
  324.    cite_acc = XmStringCreateSimple("Alt-s-t");
  325.    block = XmStringCreateSimple("Blockquote...");
  326.    block_acc = XmStringCreateSimple("Alt-s-q");
  327.    address = XmStringCreateSimple("Address...");
  328.    address_acc = XmStringCreateSimple("Alt-s-a");
  329.    bold =XmStringCreateSimple("Bold...");
  330.    bold_acc = XmStringCreateSimple("Meta-b");
  331.    italic =XmStringCreateSimple("Italic...");
  332.    italic_acc = XmStringCreateSimple("Alt-s-i");
  333.    under =XmStringCreateSimple("Underline...");
  334.    under_acc = XmStringCreateSimple("Alt-s-u");
  335.    emphasis =XmStringCreateSimple("Emphasis...");
  336.    emphasis_acc =XmStringCreateSimple("Alt-s-e");
  337.    strong =XmStringCreateSimple("Strong...");
  338.    strong_acc =XmStringCreateSimple("Alt-s-s");
  339.    ttwriter=XmStringCreateSimple("Typewriter...");
  340.    ttwriter_acc=XmStringCreateSimple("Alt-s-y");
  341.  
  342.    XmVaCreateSimplePulldownMenu(menubar,"style_menu",3,
  343.                 (XtCallbackProc)routines_styles,
  344.            XmVaPUSHBUTTON, emphasis,'E',"",dummy_acc/*emphasis_acc*/,
  345.            XmVaPUSHBUTTON, strong, 'S', "",dummy_acc/*strong_acc*/,
  346.            XmVaPUSHBUTTON, code, 'C',"",dummy_acc/*code_acc*/,
  347.            XmVaPUSHBUTTON, cite, 't',"",dummy_acc/*cite_acc*/,
  348.            XmVaPUSHBUTTON, block, 'q',"",dummy_acc/*block_acc*/,
  349.            XmVaPUSHBUTTON, address, 'A',"",dummy_acc/*address_acc*/,
  350.            /*XmVaSEPARATOR,*/
  351.            XmVaPUSHBUTTON, bold, 'B',"Meta<Key>b",bold_acc,    
  352.            XmVaPUSHBUTTON, italic, 'I',"",dummy_acc/*italic_acc*/,
  353.                    XmVaPUSHBUTTON, under, 'U',"",dummy_acc/*under_acc*/,
  354.                    XmVaPUSHBUTTON, ttwriter, 'y',"",dummy_acc/*ttwriter_acc*/,
  355.            XmNuserData,he,
  356.        NULL);
  357.    XmStringFree(code);XmStringFree(code_acc);
  358.    XmStringFree(cite);XmStringFree(cite_acc);
  359.    XmStringFree(block); XmStringFree(block_acc);
  360.    XmStringFree(address); XmStringFree(address_acc);
  361.    XmStringFree(bold);XmStringFree(bold_acc);
  362.    XmStringFree(italic);XmStringFree(italic_acc);
  363.    XmStringFree(under);XmStringFree(under_acc);
  364.    XmStringFree(emphasis);XmStringFree(strong);
  365.    XmStringFree(emphasis_acc);XmStringFree(strong_acc);
  366.    XmStringFree(ttwriter);   XmStringFree(ttwriter_acc);
  367.    
  368.  
  369.    /* Fifth menu is the Lists menu */
  370.    definition = XmStringCreateSimple("Definition");
  371.    definition_acc = XmStringCreateSimple("Meta-D");
  372.    term = XmStringCreateSimple("Term");
  373.    term_acc = XmStringCreateSimple("Meta-T");
  374.    unorder = XmStringCreateSimple("Unordered...");
  375.    unorder_acc = XmStringCreateSimple("Meta-U");
  376.    order = XmStringCreateSimple("Ordered...");
  377.    order_acc = XmStringCreateSimple("Meta-O");
  378.    item =XmStringCreateSimple("Item");
  379.    item_acc = XmStringCreateSimple("Meta-i");
  380.  
  381.    XmVaCreateSimplePulldownMenu(menubar,"list_menu",4,
  382.                 (XtCallbackProc)routines_lists,
  383.            XmVaPUSHBUTTON, definition, 'D',"Meta Shift<Key>d",definition_acc,
  384.            XmVaPUSHBUTTON, term, 'T', "Meta Shift<Key>t",term_acc,
  385.            /*XmVaSEPARATOR,*/
  386.            XmVaPUSHBUTTON, unorder, 'U',"Meta Shift<Key>u",unorder_acc,
  387.            XmVaPUSHBUTTON, order, 'O',"Meta Shift<Key>o",order_acc,
  388.            XmVaPUSHBUTTON, item, 'I',"Meta <Key>i",item_acc,
  389.            XmNuserData,he,
  390.        NULL);
  391.    XmStringFree(definition);XmStringFree(definition_acc);
  392.    XmStringFree(term);XmStringFree(term_acc);
  393.    XmStringFree(unorder); XmStringFree(unorder_acc);
  394.    XmStringFree(order); XmStringFree(order_acc);
  395.    XmStringFree(item);XmStringFree(item_acc);
  396.    
  397.    /* Sixth menu is the Characters menu */
  398.  
  399.    BuildCharactersMenu(menubar,he);
  400.  
  401.  
  402.    XmStringFree(dummy_acc);
  403.    XtManageChild(menubar);       
  404.  
  405.  
  406.    return(menubar);
  407. }
  408.  
  409. /*
  410.    
  411.    NAME : file_cb
  412.    PARAMETERS : int item_no
  413.                 Number of the item menu where this function was called for. 
  414.                 Other Parameters not used
  415.    RETURN : void
  416.    DESCRIPTION : This routine creates the FileSelectionDialog widget and
  417.                  this is shared for the option open, save and insert.
  418. */
  419. void
  420. file_cb(Widget w, int item_no, XtPointer call_data)
  421. {
  422.    Widget dialog = NULL;
  423.    XmString str=NULL, title=NULL;
  424.    XmString t=NULL;
  425.    HTMLED *he=NULL;
  426.    Widget parent = XtParent(w);
  427.    char *fname=NULL;
  428.  
  429.    XtVaGetValues(parent,XmNuserData,&he,NULL);
  430.    he->user_data = (XtPointer)item_no;
  431.    if(strcmp(he->Name_File,"*scratch*"))
  432.       t = XmStringCreateSimple(he->Name_File);
  433.  
  434.    
  435.    if(item_no == EXIT_BUT)
  436.    {
  437.       Exit_ASHE(he->textarea);
  438.       return;
  439.    }
  440.    if(item_no == CLOSE_FRAME_BUT)
  441.    {
  442.       CloseFrame(w,he);
  443.       return;
  444.    }
  445.    if(item_no == NEW_FRAME_BUT)
  446.    {
  447.       fname=he->Name_File;
  448.       if(fname)
  449.       {
  450.      XtFree(he->href);
  451.      he->href = XtMalloc(strlen(fname)+1);
  452.      strcpy(he->href,fname);
  453.       }
  454.       CreateNewFrame(w,he);
  455.       return;
  456.    }
  457.    if(item_no == EXPORT_BUT)
  458.    {
  459.       Export_HTML(w,(XtPointer)he,NULL);
  460.       return;
  461.    }
  462.    if(item_no == RELOAD_BUT)
  463.    {
  464.       Reload_HTML(w,(XtPointer)he,NULL);
  465.       return;
  466.    }
  467.    if(item_no == PRINT_BUT)
  468.    {
  469.       PrintButtonCallBack(w,(XtPointer)he,NULL);
  470.       return;
  471.    }
  472.    if(item_no == NEW_BUT)
  473.    {
  474.       new_file(he);
  475.       return;
  476.    }
  477.    if(item_no == SAVE_BUT)
  478.    {
  479.       simple_save_file(w,he);
  480.       return;
  481.    }
  482.       
  483.    if(item_no == OPEN_BUT && he->open_dialog)
  484.       dialog = he->open_dialog;
  485.    if(item_no == SAVE_AS_BUT && he->save_dialog)
  486.       dialog = he->save_dialog;
  487.    if(item_no == INSERT_BUT && he->insert_dialog)
  488.       dialog = he->insert_dialog;
  489.    
  490.    
  491.    if(dialog) {
  492.       if(t)
  493.      XtVaSetValues(dialog,
  494.                XmNtextString,t,NULL);
  495.       XtManageChild(dialog);
  496.       /* make sure that dialog is raised to top of window stack*/
  497.       XMapRaised(XtDisplay(dialog),XtWindow(XtParent(dialog)));
  498.       return;
  499.    }
  500.  
  501.    dialog = XmCreateFileSelectionDialog(he->textarea,"Files",NULL,0);
  502.    XtAddCallback(dialog,XmNcancelCallback,(XtCallbackProc)XtUnmanageChild,NULL);
  503.    XtAddCallback(dialog,XmNokCallback,OkFileButtonCallback,(XtPointer)he);
  504.    if(item_no ==OPEN_BUT)
  505.    {
  506.       str = XmStringCreateSimple("Open");
  507.       title = XmStringCreateSimple("Open File");
  508.       he->open_dialog = dialog;
  509.    }
  510.    else if(item_no == SAVE_AS_BUT)
  511.    {
  512.       str = XmStringCreateSimple("Save");
  513.       title = XmStringCreateSimple("Save File");
  514.       he->save_dialog = dialog;
  515.       if(t)
  516.      XtVaSetValues(dialog,
  517.                XmNtextString,t,NULL);
  518.    }
  519.    else if(item_no== INSERT_BUT)
  520.    {
  521.       str = XmStringCreateSimple("Insert");
  522.       title = XmStringCreateSimple("Insert File");
  523.       he->insert_dialog = dialog;
  524.    }
  525.    XtVaSetValues(dialog,
  526.          XmNokLabelString,str,
  527.          XmNdialogTitle, title,
  528.          NULL);
  529.    XmStringFree(t);
  530.    XmStringFree(str);
  531.    XmStringFree(title);
  532.    XtManageChild(dialog);
  533. }
  534.        
  535. /* 
  536.    NAME : PrintButtonCallBack
  537.    PARAMETERS : Not used
  538.    RETURN : void
  539.    DESCRIPTION : This Routine creates the dialog widget to enter
  540.                  the name of the printer
  541. */
  542.                  
  543.  
  544.  void
  545. PrintButtonCallBack(
  546.     Widget  w,
  547.     XtPointer client_data, XtPointer call_data)
  548. {
  549.    Widget dialog;
  550.    XmString title = XmStringCreateSimple("Printer Name :");
  551.    HTMLED *he = (HTMLED *)client_data;
  552.    
  553.    dialog = XmCreatePromptDialog(he->textarea,"notice_printing",NULL,0);
  554.    XtVaSetValues(dialog,XmNselectionLabelString,title,NULL);
  555.    
  556.    /* When the user choose a size of the header, call set_header */
  557.    XtAddCallback(dialog, XmNokCallback,(XtCallbackProc)printing,(XtPointer)he);
  558.    
  559.    /* If the user selects cancel, just destroy the header dialog */
  560.    XtAddCallback(dialog, XmNcancelCallback,(XtCallbackProc)XtDestroyWidget,NULL);
  561.    
  562.    /* Nor help neither text is available.... */
  563.    XtUnmanageChild(XmSelectionBoxGetChild(dialog,XmDIALOG_HELP_BUTTON));
  564.    XtManageChild(dialog);
  565. }
  566.  
  567. /* 
  568.    NAME : printing
  569.    PARAMETERS : XmSelectionBoxCallbackStruct *cbs
  570.                 This parameter has the Name of the printer
  571.    RETURN : void
  572.    DESCRIPTION : Receive the name of the printer, verify if the
  573.                  file exist and print the file in the printer
  574. */
  575.  
  576. void 
  577. printing(Widget w,XtPointer client_data,XmSelectionBoxCallbackStruct *cbs)
  578. {
  579.    HTMLED *he = (HTMLED *)client_data;
  580.    char *value=NULL;
  581.    int len=0;
  582.    char *command=NULL;
  583.  
  584.    if(XmStringGetLtoR(cbs->value,XmSTRING_DEFAULT_CHARSET,&value))
  585.       len = strlen(value);
  586.    command = XtMalloc(len+20);
  587.    strcpy(command,"lpr ");
  588.    if(strlen(value)!=0)
  589.    {
  590.       strcat(command,"-P");
  591.       strcat(command,value);
  592.       strcat(command," ");
  593.    }
  594.    if(he->Name_File[0]!='\0')
  595.    {
  596.       strcat(command,he->Name_File);
  597.       system(command);
  598.    }
  599.    else
  600.       Set_label(he->text_output,"No File to Print");
  601.  
  602.    XmProcessTraversal(he->textarea,XmTRAVERSE_CURRENT);
  603.    XtFree(command);
  604. }
  605.  
  606.  
  607. /*
  608.    
  609.    NAME : new_file
  610.    PARAMETERS : void
  611.    RETURN : void
  612.    DESCRIPTION : Set the status of the Main window for a New File
  613. */
  614. void
  615. new_file(HTMLED *he)
  616. {
  617.   char tstring[2];
  618.   tstring[0]='\0';
  619.   strcpy(he->Name_File,"*scratch*");
  620.   XmTextSetString(he->textarea,"\n");
  621.   HTMLSetText(he->html_text,tstring,NULL,NULL,0,NULL,NULL);
  622.   Set_label(he->title_output,"");
  623.   Set_label(he->text_output,"ASHE (A Simple HTML Editor)");
  624.   Set_label(he->file_output,"*scratch*");
  625. }
  626.  
  627. /*
  628.    
  629.    NAME : read_file
  630.    PARAMETERS : char *text
  631.                 Name of the file
  632.    RETURN : integer error 
  633.             returns 1 if there are some error messages
  634.    DESCRIPTION : Read the file and put it in the Text Widget
  635.                  Generates an error if the file does not exist
  636.          or could not read the entire file.
  637.  
  638. */
  639.  
  640. int
  641. read_file(char *text,HTMLED *he)
  642. {
  643.   int i=0;
  644.   int     fd;  /* File Descriptor of the file */
  645.   struct stat statbuf;        /* information on a file */
  646.   long n,file_length;            /* Length of a file */
  647.   char   *mybuf=NULL;  /* Buffer */
  648.   char buf[BUFSIZ];
  649.   char *title=NULL;
  650.   int ask;
  651.   char oldlen = (he->Name_File ? strlen(he->Name_File) : 0);
  652.   char *old_file = XtMalloc(oldlen+2);
  653.   if(he->Name_File) strcpy(old_file,he->Name_File);
  654.  
  655.   if(he->modified_file)
  656.   {
  657.      char *question=XtMalloc(oldlen+100);
  658.      sprintf(question, 
  659.         "File %s has been modified. \n Do you want to save it?",old_file);
  660.      
  661.      if((ask = AskUser(he->textarea, question))==YES)
  662.      {
  663.     if(save_file_ok(he))
  664.     {
  665.        sprintf(buf,"This file %s can not be saved",he->Name_File);
  666.        Set_label(he->text_output,buf);
  667.        XtFree(question);
  668.        return 1;
  669.     }
  670.      }
  671.      else if(ask == CANCEL)
  672.      {
  673.     XtFree(question);
  674.     return 1;
  675.      }
  676.      XtFree(question);
  677.   }
  678.  
  679.   he->Name_File[0]='\0'; 
  680.   
  681.   strcpy(he->Name_File,text);
  682.  
  683.  
  684.   if(stat(he->Name_File, &statbuf) == 0)
  685.     file_length = statbuf.st_size;
  686.   else 
  687.     file_length = BUFSIZ;
  688.  
  689.   /* The name of the file is a directory ? */
  690.   if(he->Name_File)
  691.   {
  692.      if(S_ISDIR(statbuf.st_mode))
  693.      {
  694.     fprintf(stderr,"%s is a directory\n\n",he->Name_File);
  695.     sprintf(buf,"%s is a directory",he->Name_File);
  696.     Set_label(he->text_output,buf);
  697.     return 1;
  698.      }
  699.   }
  700.  
  701.   /* Create the space for the file */
  702.  
  703.   mybuf = (char *)XtMalloc((unsigned)file_length+1);
  704.  
  705.   if (mybuf == NULL)
  706.     {
  707.       fprintf(stderr," File is too big \n");
  708.       sprintf(buf,"%s: XtMalloc(%ld) failed",text,file_length);
  709.       Set_label(he->text_output,buf);
  710.       return 1;
  711.     }
  712.   fprintf(stdout, "File :'%s'\n", he->Name_File);
  713.  
  714.   /* Opening and Reading the file */
  715.   if((fd = open(he->Name_File,O_RDONLY,0)) == -1)
  716.     {
  717.       fprintf(stderr,"File %s does not exist\n\n",he->Name_File);
  718.       sprintf(buf,"File %s does not exist",he->Name_File);
  719.       Set_label(he->text_output,buf);
  720.       return 1;
  721.     }
  722.  
  723.   while((n = read(fd, mybuf, file_length)) > 0)
  724.     {
  725.        if(n!=file_length)
  726.       sprintf(buf,"Warning: did not read entire file!");
  727.        else
  728.       sprintf(buf,"Loaded %ld bytes from %s",file_length,text);
  729.       i++;
  730.       if (i==2) printf("Reading the buffer again\n");
  731.     }
  732.   mybuf[file_length]=0; /* NULL-terminate */
  733.   XmTextSetString(he->textarea,mybuf);
  734.   HTMLSetText(he->html_text,mybuf,NULL,NULL,0,he->anchor_target,NULL);
  735.   
  736.   if(he->toggle_mark_tag == True)
  737.      parsing_hightlight(mybuf,0,0,he);
  738.  
  739.   title = get_title(he->html_text);
  740.   if(title!=NULL)
  741.      Set_label(he->title_output,title);
  742.   else
  743.      Set_label(he->title_output,"");
  744.      
  745.  
  746.   Set_label(he->text_output,buf);
  747.   Set_label(he->file_output,text);
  748.   he->modified_file = FALSE;
  749.   XtFree(mybuf);
  750.   /*XtFree(text); Bki */
  751.   XtFree(title);
  752.   close(fd);
  753.   return 0;
  754. }
  755.  
  756. void 
  757. simple_save_file(Widget w,HTMLED *he)
  758. {
  759.    if(strcmp(he->Name_File,"*scratch*"))
  760.       save_file_ok(he);
  761.    else
  762.       file_cb(w,SAVE_AS_BUT,NULL);
  763. }
  764.       
  765.       
  766.  
  767. /*
  768.    
  769.    NAME : save_file
  770.    PARAMETERS : char *filename
  771.                 Name of the file
  772.    RETURN : integer error 
  773.             returns 1 if there are some error messages
  774.    DESCRIPTION : Takes the string from the Text Widget and Save it in the
  775.                  given file name
  776.          If the file does not exist, create a new file
  777.  
  778. */
  779. int
  780. save_file(char *filename,HTMLED *he)
  781. {
  782.    int fd;
  783.    int len=0;
  784.  
  785.    if((fd = open(filename,O_RDONLY,0)) == -1)
  786.    {
  787.       strcpy(he->Name_File,filename);
  788.       close(fd);
  789.       return(save_file_ok(he));
  790.    }
  791.    else
  792.    {
  793.       len = strlen(filename);
  794.       close(fd);
  795.       he->warning = XtMalloc(len+50);
  796.       sprintf(he->warning,
  797.           "\"%s\" already exists\nDo you want to overwrite it?",filename);
  798.       warning_message(he->textarea,he);
  799.    }
  800.    return 0;
  801. }
  802.  
  803. void
  804. warning_message(Widget w,HTMLED *he)
  805. {
  806.    static Widget dialog;
  807.    XmString text,ok_str,cancel_str;
  808.    char *msg = he->warning;
  809.    
  810.    if(!dialog)
  811.       dialog = XmCreateWarningDialog(w,"warning",NULL,0);
  812.    text = XmStringCreateLtoR(msg,XmFONTLIST_DEFAULT_TAG);
  813.    ok_str = XmStringCreateLocalized("Yes");
  814.    cancel_str = XmStringCreateLocalized("No");
  815.    XtVaSetValues(dialog,
  816.          XmNmessageString,text,
  817.          XmNokLabelString,ok_str,
  818.          XmNcancelLabelString,cancel_str,
  819.          NULL);
  820.    XtAddCallback(dialog,XmNokCallback,(XtCallbackProc)ok_pushed,(XtPointer)he);
  821.    XmStringFree(text);
  822.    XmStringFree(ok_str);
  823.    XmStringFree(cancel_str);
  824.    XtFree(he->warning);
  825.    
  826.    XtManageChild(dialog);
  827.    XtPopup(XtParent(dialog),XtGrabNone);
  828. }
  829.    
  830. void
  831. ok_pushed(Widget w, XtPointer client_data,XtPointer call_data)
  832. {
  833.    char *filename;
  834.    HTMLED *he = (HTMLED *)client_data;
  835.    Widget text = XmFileSelectionBoxGetChild(he->save_dialog,XmDIALOG_TEXT);
  836.    filename = XmTextGetString(text);
  837.    strcpy(he->Name_File,filename);
  838.    XtFree(filename);   
  839.    save_file_ok(he);
  840.    if(he->save_dialog)
  841.       XtUnmanageChild(he->save_dialog);
  842. }
  843.  
  844. int 
  845. save_file_ok(HTMLED *he)
  846. {
  847.    char   *tstring=NULL;        /* text string */
  848.    int fd,fdb;
  849.    int n;
  850.    int file_length;
  851.    char buf[BUFSIZ];
  852.    long len;
  853.    char *filename = he->Name_File;
  854.    char *fileback=NULL;
  855.    struct stat statbuf;
  856.  
  857.  
  858.    /* Create a Back up file */
  859.  
  860.    if((fd = open(filename,O_RDONLY,0)) != -1)
  861.    {
  862.       fileback = XtMalloc(strlen(filename)+2);
  863.       sprintf(fileback,"%s~",filename);
  864.       if((fdb = creat(fileback,PERMS)) == -1)
  865.       {
  866.      perror("Can not save this file \n");
  867.      sprintf(buf,"Can't save to %s.",fileback);
  868.      Set_label(he->text_output,buf);
  869.      return 1;
  870.       }
  871.       if(stat(he->Name_File, &statbuf) == 0)
  872.      file_length = statbuf.st_size;
  873.       else 
  874.      file_length = BUFSIZ;
  875.       tstring = XtMalloc(file_length +2);
  876.       while((n = read(fd, tstring, file_length)) > 0)
  877.      if(write(fdb, tstring, n) != n)
  878.      {
  879.         printf("File %s is not saved \n",fileback);
  880.         he->modified_file = TRUE;
  881.      }
  882.       he->modified_file = FALSE;
  883.       close(fdb);
  884.       close(fd);
  885.       XtFree(tstring);
  886.       XtFree(fileback);
  887.    }
  888.     
  889.    /* Create the file if it is a new file and write the
  890.       content of the Text Window to the file */
  891.    if((fd = creat(filename,PERMS)) == -1)
  892.    {
  893.       perror("Can not save this file \n");
  894.       sprintf(buf,"Can't save to %s.",filename);
  895.       Set_label(he->text_output,buf);
  896.       return 1;
  897.    }
  898.  
  899.    /* saving -- get text for Text widget... */
  900.  
  901.    tstring = XmTextGetString(he->textarea);
  902.    len = XmTextGetLastPosition(he->textarea);
  903.    if(write(fd,tstring,len)!= len)
  904.       strcpy(buf,"Warning: did not write entire file!");
  905.    else
  906.    {
  907.       /* make sure a newline terminates file */
  908.       if(tstring[len-1]!='\n')
  909.       {
  910.      strcpy(buf,"\n");
  911.      ++len; /* Bki */
  912.      write(fd,buf,1);
  913.       }
  914.       sprintf(buf,"saved %ld bytes to %s.",len, filename);
  915.    }
  916.    XtFree(tstring);
  917.    Set_label(he->text_output,buf);
  918.    Set_label(he->file_output,filename);
  919.    close(fd);
  920.    return 0;
  921. }
  922. /*
  923.    
  924.    NAME : insert_file
  925.    PARAMETERS : char *text
  926.                 Name of the file
  927.    RETURN : integer error 
  928.             returns 1 if there are some error messages
  929.    DESCRIPTION : Read the file and insert it in the Text Widget in
  930.                  the position where the cursor is.  
  931.                  Generates an error if the file does not exist
  932.          or could not read the entire file.
  933.  
  934. */
  935. int 
  936. insert_file(char *text,HTMLED *he)
  937. {
  938.   int i=0;
  939.   int     fd;  /* File Descriptor of the file */
  940.   struct stat statbuf;        /* information on a file */
  941.   long n,file_length;            /* Length of a file */
  942.   char   *mybuf;  /* Buffer */
  943.   char buf[BUFSIZ];
  944.   char fname[MAXIPATH];
  945.   char *title;
  946.   XmTextPosition left,right;
  947.   fname[0]='\0'; 
  948.   /* Read the name of the file in the current directory or 
  949.      full name of the file */
  950. /*  if(text[0]!='/')
  951.     {
  952.       strcpy(fname, Home);
  953.       strcat(fname,"/");
  954.       strcat(fname, text);
  955.     }
  956.   else */
  957.     strcpy(fname,text);
  958.  
  959.   if(stat(fname, &statbuf) == 0)
  960.     file_length = statbuf.st_size;
  961.   else 
  962.     file_length = BUFSIZ;
  963.  
  964.   /* Create the space for the file */
  965.  
  966.   mybuf = (char *)XtMalloc((unsigned)file_length);
  967.  
  968.   if (mybuf == NULL)
  969.     {
  970.       fprintf(stderr," File is too big \n");
  971.       sprintf(buf,"%s: XtMalloc(%ld) failed",text,file_length);
  972.       Set_label(he->text_output,buf);
  973.       return 1;
  974.     }
  975.   fprintf(stdout, "You typed '%s'\n", fname);
  976.  
  977.   /* Opening and Reading the file */
  978.   if((fd = open(fname,O_RDONLY,0)) == -1)
  979.     {
  980.       fprintf(stderr,"File %s does not exist\n\n",fname);
  981.       sprintf(buf,"File %s does not exist",fname);
  982.       Set_label(he->text_output,buf);
  983.       return 1;
  984.     }
  985.   
  986.   while((n = read(fd, mybuf, file_length)) > 0)
  987.     {
  988.        if(n!=file_length)
  989.       sprintf(buf,"Warning: did not read entire file!");
  990.        else
  991.       sprintf(buf,"Loaded %ld bytes from %s",file_length,text);
  992.       i++;
  993.       if (i==2) printf("Reading the buffer again\n");
  994.     }
  995.   mybuf[file_length]=0; /* NULL-terminate */
  996.   left = XmTextGetInsertionPosition(he->textarea);
  997.   XmTextInsert(he->textarea,left,mybuf);
  998.   XtFree(mybuf);
  999.   mybuf= XmTextGetString(he->textarea);
  1000.   HTMLSetText(he->html_text,mybuf,NULL,NULL,0,NULL,NULL);
  1001.   title=remove_title(&left,&right,he);
  1002.   if(left!=0)
  1003.      Set_label(he->title_output,title);
  1004.   Set_label(he->text_output,buf);
  1005.   XtFree(mybuf);
  1006.   /*XtFree(text);*/
  1007.   XtFree(title);
  1008.   close(fd);
  1009.   return 0;
  1010.   
  1011. }
  1012. /*
  1013.    
  1014.    NAME : OkFileButtonCallback
  1015.    PARAMETERS : int save
  1016.                 Integer to know what dialog widget call this function.
  1017.    RETURN : void
  1018.    DESCRIPTION : This is a Callback function that is called when
  1019.                  the OK button is selected. It decides if the file
  1020.          is going to be saved, opened or inserted.
  1021.  
  1022. */
  1023. void 
  1024. OkFileButtonCallback(
  1025.     Widget  w,
  1026.     XtPointer client_data, XtPointer call_data)
  1027. {
  1028.     HTMLED *he = (HTMLED *)client_data;
  1029.     int save = (int)he->user_data;
  1030.     XmFileSelectionBoxCallbackStruct *selection;
  1031.     char  *filename;
  1032.     int flag;
  1033.    
  1034.     /* The information about the selection is passed in call_data. */
  1035.     selection = (XmFileSelectionBoxCallbackStruct *) call_data;
  1036.  
  1037.     /* Read the file and show it in the Text Window */
  1038.     
  1039.     if(!XmStringGetLtoR(selection->value,XmSTRING_DEFAULT_CHARSET,&filename))
  1040.        return; /* must have been an internal error */
  1041.     if(!*filename)
  1042.     {
  1043.        /*XtFree(filename);*/
  1044.        XBell(XtDisplay(he->textarea),50);
  1045.        Set_label(he->text_output,"Choose a file.");
  1046.        return; /* nothing typed */
  1047.     }
  1048.     if(save == SAVE_AS_BUT)
  1049.        flag = save_file(filename,he);
  1050.     else if(save ==OPEN_BUT)
  1051.        flag = read_file(filename,he);
  1052.     else if(save == INSERT_BUT)
  1053.        flag = insert_file(filename,he);
  1054.     /* free all allocated space */
  1055.     /*XtFree(filename);*/
  1056.     if(!flag)
  1057.        XtUnmanageChild(w);
  1058.  }
  1059.  
  1060. /*
  1061.    
  1062.    NAME : ClearButtonCallBack
  1063.    PARAMETERS : Not used
  1064.    RETURN : void
  1065.    DESCRIPTION : Clear the text window
  1066.  
  1067. */
  1068.  
  1069.  void
  1070. ClearButtonCallBack(
  1071.     Widget  w,
  1072.     XtPointer client_data,XtPointer call_data)
  1073. {
  1074.    HTMLED *he = (HTMLED *)client_data;
  1075.    char tstring[2];
  1076.    if(he->text_cleared)
  1077.    {
  1078.       XtFree(he->text_cleared);
  1079.       he->text_cleared = NULL;
  1080.    }
  1081.    he->text_cleared = XmTextGetString(he->textarea);
  1082.    tstring[0]='\0';
  1083.    he->last_command = CLEAR;
  1084.    XmTextSetString(he->textarea, "");
  1085.    HTMLSetText(he->html_text,tstring,NULL,NULL,0,NULL,NULL); 
  1086.    Set_label(he->title_output,"");
  1087.    XmProcessTraversal(he->textarea,XmTRAVERSE_CURRENT);
  1088. /*
  1089.    
  1090.    NAME : Set_label
  1091.    PARAMETERS : Widget w
  1092.                 Label Widget to be modified its label 
  1093.         char *label
  1094.         Name of the new label of the Widget
  1095.    RETURN : void
  1096.    DESCRIPTION : Set the label of a Label Widget
  1097.  
  1098. */
  1099.  
  1100.  
  1101. void 
  1102. Set_label(Widget w,char *label)
  1103. {
  1104.    XmString str = XmStringCreateLtoR(label,XmSTRING_DEFAULT_CHARSET);
  1105.    XmString str2=NULL,str3=NULL;
  1106.    if(!strcmp(XtName(w),"title_out"))
  1107.    {
  1108.       str2 = XmStringCreateLtoR(" Document Title : ",XmSTRING_DEFAULT_CHARSET);
  1109.       str3 = XmStringConcat(str2,str);
  1110.    }
  1111.    else if(!strcmp(XtName(w),"file_out"))
  1112.    {
  1113.       str2 = XmStringCreateLtoR("File Name : ",XmSTRING_DEFAULT_CHARSET);
  1114.       str3 = XmStringConcat(str2,str);
  1115.    }
  1116.    else
  1117.       str3 = XmStringCopy(str);
  1118.  
  1119. /*   XmStringGetLtoR(str,XmSTRING_DEFAULT_CHARSET,&value1);
  1120.    XmStringGetLtoR(str2,XmSTRING_DEFAULT_CHARSET,&value2);
  1121.    XmStringGetLtoR(str3,XmSTRING_DEFAULT_CHARSET,&value3);
  1122.    printf("3 values: %s\t%s\t%s\n",value1,value2,value3);
  1123.    XtFree(value1);
  1124.    XtFree(value2);
  1125.    XtFree(value3);*/
  1126.  
  1127.    XtVaSetValues(w,XmNlabelString,str3,NULL);
  1128.    
  1129.    XmStringFree(str);
  1130.    
  1131.    if(str2!=NULL)
  1132.       XmStringFree(str2);
  1133.    if(str3!=NULL)
  1134.       XmStringFree(str3);
  1135.  
  1136. }
  1137. /*
  1138.    
  1139.    NAME : cut_paste
  1140.    PARAMETERS : int item_no
  1141.                 Item number of the Edit Menu where this function was called
  1142.    RETURN : void
  1143.    DESCRIPTION : Depending of the item_no, it decides to cut, copy, paste
  1144.                  delete or undo
  1145.  
  1146. */
  1147. void 
  1148. cut_paste(Widget w, int item_no)
  1149. {
  1150.    HTMLED *he;
  1151.    Boolean result = True;
  1152.    static Boolean flag = True;
  1153.    Widget parent = XtParent(w);
  1154.    XtVaGetValues(parent,XmNuserData,&he,NULL);
  1155.    switch(item_no) {
  1156.    case 0: 
  1157.       result = XmTextCut(he->textarea,CurrentTime); break;
  1158.    case 1: 
  1159.       result = XmTextCopy(he->textarea,CurrentTime); break;
  1160.    case 2: 
  1161.       result = XmTextPaste(he->textarea); break;
  1162.    case 3: 
  1163.       XmTextClearSelection(he->textarea,CurrentTime); break;
  1164.    case 4:
  1165.       create_undo(w,he);
  1166.    }
  1167.    if (result == False)
  1168.       Set_label(he->text_output, "There is no selection");
  1169.    else
  1170.    {
  1171.       if(flag==True)
  1172.       {
  1173.      XtSetSensitive(XtNameToWidget(XtParent(w),"button_2"),True);
  1174.      flag = False;
  1175.       }
  1176.       Set_label(he->text_output, "");
  1177.    }
  1178. }
  1179.  
  1180. /*
  1181.    
  1182.    NAME : Setmenu
  1183.    PARAMETERS : Not used
  1184.    RETURN : void
  1185.    DESCRIPTION :This function sets the items cut and copy to
  1186.         be sensitive or not depending if there is
  1187.         a selected text or not
  1188.  
  1189. */
  1190. void 
  1191. Setmenu(Widget w,HTMLED *he)
  1192. {
  1193.    XmTextPosition left,right;
  1194.    Boolean flag;
  1195.  
  1196.    flag = XmTextGetSelectionPosition(he->textarea,&left,&right);
  1197.    if((flag == True) && (left!=right))
  1198.    {
  1199.       XtSetSensitive(XtNameToWidget(he->editwidget,"button_0"),True);
  1200.       XtSetSensitive(XtNameToWidget(he->editwidget,"button_1"),True);
  1201.    }
  1202.    else
  1203.    {
  1204.       XtSetSensitive(XtNameToWidget(he->editwidget,"button_0"),False);
  1205.       XtSetSensitive(XtNameToWidget(he->editwidget,"button_1"),False);
  1206.    }  
  1207. }
  1208.  
  1209. /*
  1210.    NAME : parsing_hightlight
  1211.    PARAMETERS : char *text
  1212.                 String from the insertion point to the end of the text
  1213.                 XmTextPosition start
  1214.         Insertion Point
  1215.         int count
  1216.         Number of characters that are inserted to the text
  1217.    RETURN : void
  1218.    DESCRIPTION : This routine update the underlining of all tags
  1219.                  from the insertion point to the end of the text
  1220. */
  1221.  
  1222. void 
  1223. parsing_hightlight(char *text,XmTextPosition start,int count,HTMLED *he)
  1224. {
  1225.    int i;
  1226.    int len=0;
  1227.    XmTextPosition left=0,right=0,before=0;
  1228.    
  1229.    if(text)
  1230.       len = strlen(text);
  1231.    right = len;
  1232.  
  1233.    for(i=start;i<len;)
  1234.    {
  1235.       while(text[i]!='<')
  1236.       {
  1237.      i++;
  1238.      if(text[i]=='>')
  1239.      {
  1240.         Set_label(he->text_output,"Overlapped HTML Tags");
  1241.      }
  1242.      if (i == len) break;
  1243.       }
  1244.       before = i;
  1245.       left = i+count;
  1246.       if(i==len) break;
  1247.       while(text[i]!='>')
  1248.       {
  1249.      i++;
  1250.      if(text[i]=='<')
  1251.      {
  1252.         Set_label(he->text_output,"Overlapped HTML Tags");
  1253.      }
  1254.      if (i == len) break;
  1255.       }
  1256.       right = i+count;
  1257.       if(i== len) break;
  1258.       XmTextSetHighlight(he->textarea,left,right,XmHIGHLIGHT_SECONDARY_SELECTED);
  1259.       XmTextSetHighlight(he->textarea,before-1,left-1,XmHIGHLIGHT_NORMAL);
  1260.    }
  1261. }
  1262. /*
  1263.    
  1264.    NAME : Set_Underline_Tags
  1265.    PARAMETERS : XmToggleButtonCallbackStruct *state
  1266.                 This gives the state of the toggle button mark tags
  1267.    RETURN : void
  1268.    DESCRIPTION :This is a Callback function that is called when
  1269.                 the toggle button mark_tags change the state.
  1270.         If it is on, the document is parsed to underline
  1271.         all tags.
  1272.  
  1273. */
  1274.  
  1275.  
  1276. void 
  1277. Set_Underline_Tags(Widget w, 
  1278.            XtPointer client_data,
  1279.            XmToggleButtonCallbackStruct *state)
  1280. {
  1281.    HTMLED *he = (HTMLED *)client_data;
  1282.    char * text;
  1283.    he->toggle_mark_tag = False;
  1284.    if (state->set)
  1285.    {
  1286.       he->toggle_mark_tag = True;
  1287.       text = XmTextGetString(he->textarea);
  1288.       parsing_hightlight(text,0,0,he);
  1289.       XtFree(text);
  1290.    }
  1291.    else
  1292.       XmTextSetHighlight(he->textarea,0,XmTextGetLastPosition(he->textarea),
  1293.              XmHIGHLIGHT_NORMAL);
  1294.    XmProcessTraversal(he->textarea,XmTRAVERSE_CURRENT);
  1295. }
  1296.     
  1297. /*
  1298.    AskUser() --- a generalized routine that asks the user a question
  1299.    and return the Yes/No response
  1300. */
  1301. int 
  1302. AskUser(Widget parent, char *question)
  1303. {
  1304.    Widget dialog;
  1305.    XmString text, yes, no,cancel_str;
  1306.    static int answer;
  1307.    
  1308.    dialog = XmCreateQuestionDialog(parent, "dialog",NULL,0);
  1309.    yes = XmStringCreateLocalized("Yes");
  1310.    no = XmStringCreateLocalized("No");
  1311.    cancel_str =  XmStringCreateLocalized("Cancel");
  1312.    XtVaSetValues(dialog,
  1313.          XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
  1314.          XmNokLabelString, yes,
  1315.          XmNcancelLabelString, no,
  1316.          XmNhelpLabelString,cancel_str,
  1317.          NULL);
  1318.    XtAddCallback(dialog,XmNokCallback, response, (XtPointer)&answer);
  1319.    XtAddCallback(dialog,XmNcancelCallback, response,(XtPointer)&answer);
  1320.    XtAddCallback(dialog,XmNhelpCallback, response,(XtPointer)&answer); 
  1321.    XmStringFree(yes);
  1322.    XmStringFree(no);   XmStringFree(cancel_str);
  1323.    
  1324.    answer = 0;
  1325.    text = XmStringCreateLtoR(question,XmSTRING_DEFAULT_CHARSET);
  1326.    XtVaSetValues(dialog,
  1327.          XmNmessageString, text,
  1328.          NULL);
  1329.    XmStringFree(text);
  1330.    XtManageChild(dialog);
  1331.    XtPopup(XtParent(dialog), XtGrabNone);
  1332.    /* while the user hasn't provided an answer, simulate main loop.
  1333.       the answer changes as soon as the user selects one of the buttons
  1334.       and the callback routine changes its value.
  1335.     */
  1336.    while(answer == 0)
  1337.       XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll);
  1338.    XtPopdown(XtParent(dialog));
  1339.    return answer;
  1340. }
  1341. /*
  1342.    response() -- The user made some sort of response to the question
  1343.    posed in AskUser(). Set the answer (client_data)
  1344.    accordingly and destroy the dialog.
  1345. */
  1346.  
  1347. void 
  1348. response(Widget widget, XtPointer client_data, XtPointer call_data)
  1349. {
  1350.    int *answer = (int *)client_data;
  1351.    XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
  1352.    switch(cbs->reason) {
  1353.    case XmCR_OK:
  1354.       *answer = YES;
  1355.       break;
  1356.    case XmCR_CANCEL:
  1357.       *answer = NO;
  1358.       break;
  1359.    case XmCR_HELP:
  1360.       *answer = CANCEL;
  1361.       break;
  1362.    default:
  1363.       return;
  1364.    }
  1365. }
  1366.      
  1367.  
  1368. void
  1369. Export_HTML(
  1370.     Widget  w,
  1371.     XtPointer client_data, XtPointer call_data)
  1372. {
  1373.    HTMLED *he = (HTMLED *)client_data;
  1374.    Widget dialog= he->export_dialog;
  1375.    Widget menu_export;
  1376.    int item_no = (int)he->user_data;
  1377.    XmString str,title;
  1378.  
  1379.    if(dialog) {
  1380. /*      if(t)
  1381.      XtVaSetValues(dialog,
  1382.                XmNtextString,t,NULL);*/
  1383.       XtManageChild(dialog);
  1384.       /* make sure that dialog is raised to top of window stack*/
  1385.       XMapRaised(XtDisplay(dialog),XtWindow(XtParent(dialog)));
  1386.       return;
  1387.    }
  1388.  
  1389.    dialog = XmCreateFileSelectionDialog(he->textarea,"Files",NULL,0);
  1390.    {
  1391.    XmString label= XmStringCreateSimple("Format for exported document: ");
  1392.    XmString Text = XmStringCreateSimple("Plain Text");
  1393.    XmString Form_Text = XmStringCreateSimple("Formatted Text");
  1394.    XmString PS_Times= XmStringCreateSimple("PostScript");
  1395.    
  1396.  
  1397.    menu_export = XmVaCreateSimpleOptionMenu(dialog,"menu_export",
  1398.          label,'\0',0,(XtCallbackProc)export_cb,
  1399.          XmVaPUSHBUTTON,Text ,'T',NULL,NULL,
  1400.          XmVaPUSHBUTTON,Form_Text ,'F',NULL,NULL,
  1401.          XmVaPUSHBUTTON,PS_Times, 'm',NULL,NULL,
  1402.                  XmNuserData,he,                       
  1403.          NULL);
  1404.    XmStringFree(Text ); XmStringFree(PS_Times);
  1405.    XmStringFree(Form_Text );
  1406.    XtManageChild(menu_export);
  1407.    }
  1408.  
  1409.    XtAddCallback(dialog,XmNcancelCallback,(XtCallbackProc)XtUnmanageChild,NULL);
  1410.    XtAddCallback(dialog,XmNokCallback,(XtCallbackProc)OkExportButtonCallback,(XtPointer)he);
  1411.    if(item_no ==EXPORT_BUT)
  1412.    {
  1413.       str = XmStringCreateSimple("Export");
  1414.       title = XmStringCreateSimple("Export HTML Document");
  1415.       he->export_dialog = dialog;
  1416.    }
  1417.    XtVaSetValues(dialog,
  1418.          XmNokLabelString,str,
  1419.          XmNdialogTitle, title,
  1420.          NULL);
  1421.    XmStringFree(str);
  1422.    XmStringFree(title);
  1423.    XtManageChild(dialog);
  1424. }
  1425. void
  1426. export_cb(Widget w, XtPointer client_data, XtPointer call_data)
  1427. {
  1428.    int item_no = (int)client_data;
  1429.    Widget parent = XtParent(w);
  1430.    HTMLED *he;
  1431.    XtVaGetValues(parent,XmNuserData,&he,NULL);
  1432.    he->export_option = item_no;
  1433. }
  1434. void
  1435. OkExportButtonCallback(Widget w, XtPointer client_data, XtPointer call_data)
  1436. {
  1437.    int fd;
  1438.    HTMLED  *he = (HTMLED *)client_data;
  1439.    int len=0;
  1440.    char *filename;
  1441.    XmFileSelectionBoxCallbackStruct *selection = 
  1442.       (XmFileSelectionBoxCallbackStruct *) call_data;
  1443.    /* Read the file and show it in the Text Window */
  1444.     
  1445.     if(!XmStringGetLtoR(selection->value,XmSTRING_DEFAULT_CHARSET,&filename))
  1446.        return; /* must have been an internal error */
  1447.    
  1448.    if(!*filename)
  1449.     {
  1450.        /*XtFree(filename);*/
  1451.        XBell(XtDisplay(he->textarea),50);
  1452.        Set_label(he->text_output,"Choose a file.");
  1453.        return; /* nothing typed */
  1454.     }
  1455.    XtFree(he->format_file);
  1456.    he->format_file = filename;
  1457.    if((fd = open(filename,O_RDONLY,0)) != -1)
  1458.    {
  1459.       len = strlen(filename);
  1460.       he->warning = XtMalloc(len+50);
  1461.       sprintf(he->warning,
  1462.           "\"%s\" already exists\nDo you want to overwrite it?",filename);
  1463.       warning_format_file(he->textarea,he);
  1464.    }
  1465.    else
  1466.    {
  1467.       save_format_file(he);
  1468.       if(he->export_dialog)
  1469.      XtUnmanageChild(he->export_dialog);
  1470.    }
  1471. }
  1472. void
  1473. warning_format_file(Widget w,HTMLED *he)
  1474. {
  1475.    static Widget dialog;
  1476.    XmString text,ok_str,cancel_str;
  1477.    char *msg = he->warning;
  1478.    
  1479.    if(!dialog)
  1480.       dialog = XmCreateWarningDialog(w,"warning",NULL,0);
  1481.    text = XmStringCreateLtoR(msg,XmFONTLIST_DEFAULT_TAG);
  1482.    ok_str = XmStringCreateLocalized("Yes");
  1483.    cancel_str = XmStringCreateLocalized("No");   XtVaSetValues(dialog,
  1484.          XmNmessageString,text,
  1485.          XmNokLabelString,ok_str,
  1486.          XmNcancelLabelString,cancel_str,
  1487.          NULL);
  1488.    XtAddCallback(dialog,XmNokCallback,(XtCallbackProc)ok_format_file,
  1489.          (XtPointer)he);
  1490.    XmStringFree(text);
  1491.    XmStringFree(ok_str);
  1492.    XmStringFree(cancel_str);
  1493.    XtFree(he->warning);
  1494.    
  1495.    XtManageChild(dialog);
  1496.    XtPopup(XtParent(dialog),XtGrabNone);
  1497. }
  1498.  
  1499. void
  1500. ok_format_file(Widget w, XtPointer client_data,XtPointer call_data)
  1501. {
  1502.    HTMLED *he = (HTMLED *)client_data;
  1503.    save_format_file(he);   
  1504.    if(he->export_dialog)
  1505.       XtUnmanageChild(he->export_dialog);
  1506. }
  1507.  
  1508. void
  1509. save_format_file(HTMLED *he)
  1510. {
  1511.    char *text=NULL;
  1512.    long int len;
  1513.    int fd;
  1514.    char buf[BUFSIZ];
  1515.    char *filename = he->format_file;
  1516.    if(!(he->format_file))
  1517.       return;
  1518.    buf[0]='\0';
  1519.    printf("File to be saved is %s\n",he->format_file);
  1520.    /* Create the file if it is a new file and write the
  1521.       content of the Text Window to the file */
  1522.    if((fd = creat(filename,PERMS)) == -1)
  1523.    {
  1524.       perror("Can not save this file \n");
  1525.       sprintf(buf,"Can't save to %s.",filename);
  1526.       Set_label(he->text_output,buf);
  1527.       return ;
  1528.    }
  1529.  
  1530.    if(he->export_option==POSTSCRIPT)
  1531.       text = HTMLGetText(he->html_text,he->export_option+he->fonts);
  1532.    else
  1533.       text = HTMLGetText(he->html_text,he->export_option);
  1534.    /*len = strlen(text)+1;*/
  1535.    len = strlen(text);
  1536.    if(write(fd,text,len)!= len)
  1537.       strcpy(buf,"Warning: did not write entire file!");
  1538.    else
  1539.    {
  1540.       /* make sure a newline terminates file */
  1541.       if(text[len-1]!='\n')
  1542.       {
  1543.      strcpy(buf,"\n");
  1544.      ++len; /* BKi */
  1545.      write(fd,buf,1);
  1546.       }
  1547.       sprintf(buf,"saved %ld bytes to %s.",len, filename);
  1548.    }
  1549.    XtFree(text);
  1550.    Set_label(he->text_output,buf);
  1551.    close(fd);
  1552.  
  1553.    XtFree(he->format_file);
  1554.    he->format_file = NULL;
  1555. }
  1556. void
  1557. routines_fonts(Widget w, XtPointer client_data,XtPointer call_data)
  1558. {
  1559.    int item_no=(int )client_data;
  1560.    HTMLED *he;
  1561.    Widget whtml;
  1562.    Widget parent = XtParent(w);
  1563.    XtVaGetValues(parent,XmNuserData,&he,NULL);
  1564.    whtml = he->html_text;
  1565.    switch(item_no)
  1566.    {
  1567.    case TREGULAR:
  1568.       XtVaSetValues(whtml,
  1569.        XtNfont,
  1570.            getFont("-adobe-times-medium-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1571.            WbNitalicFont, 
  1572.            getFont("-adobe-times-medium-i-normal-*-17-*-*-*-*-*-*-*",whtml),
  1573.            WbNboldFont, 
  1574.            getFont("-adobe-times-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1575.        WbNfixedFont, 
  1576.            getFont("-adobe-courier-medium-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1577.        WbNfixedboldFont, 
  1578.            getFont("-adobe-courier-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1579.        WbNfixeditalicFont, 
  1580.        getFont("-adobe-courier-medium-o-normal-*-17-*-*-*-*-*-*-*",whtml),
  1581.        WbNheader1Font, 
  1582.        getFont("-adobe-times-bold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1583.        WbNheader2Font, 
  1584.            getFont("-adobe-times-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1585.        WbNheader3Font, 
  1586.            getFont("-adobe-times-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1587.            WbNheader4Font, 
  1588.        getFont("-adobe-times-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1589.        WbNheader5Font, 
  1590.            getFont("-adobe-times-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1591.            WbNheader6Font, 
  1592.            getFont("-adobe-times-bold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1593.        WbNaddressFont, 
  1594.        getFont("-adobe-times-medium-i-normal-*-17-*-*-*-*-*-*-*",whtml),
  1595.        WbNplainFont, 
  1596.        getFont("-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1597.        WbNplainboldFont, 
  1598.        getFont("-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1599.        WbNplainitalicFont, 
  1600.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1601.        NULL);
  1602.       he->fonts = TIMES;
  1603.       break;
  1604.    case TSMALL:
  1605.       XtVaSetValues(whtml,
  1606.        XtNfont,
  1607.            getFont("-adobe-times-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1608.            WbNitalicFont, 
  1609.            getFont("-adobe-times-medium-i-normal-*-14-*-*-*-*-*-*-*",whtml),
  1610.            WbNboldFont, 
  1611.            getFont("-adobe-times-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1612.        WbNfixedFont, 
  1613.            getFont("-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1614.        WbNfixedboldFont, 
  1615.            getFont("-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1616.        WbNfixeditalicFont, 
  1617.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1618.        WbNheader1Font, 
  1619.        getFont("-adobe-times-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1620.        WbNheader2Font, 
  1621.            getFont("-adobe-times-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1622.        WbNheader3Font, 
  1623.            getFont("-adobe-times-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1624.            WbNheader4Font, 
  1625.        getFont("-adobe-times-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1626.        WbNheader5Font, 
  1627.            getFont("-adobe-times-bold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1628.            WbNheader6Font, 
  1629.            getFont("-adobe-times-bold-r-normal-*-8-*-*-*-*-*-*-*",whtml),
  1630.        WbNaddressFont, 
  1631.        getFont("-adobe-times-medium-i-normal-*-14-*-*-*-*-*-*-*",whtml),
  1632.        WbNplainFont, 
  1633.        getFont("-adobe-courier-medium-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1634.        WbNplainboldFont, 
  1635.        getFont("-adobe-courier-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1636.        WbNplainitalicFont, 
  1637.        getFont("-adobe-courier-medium-o-normal-*-12-*-*-*-*-*-*-*",whtml),
  1638.        NULL);
  1639.       he->fonts = TIMES;
  1640.       break;
  1641.    case TLARGE:
  1642.       XtVaSetValues(whtml,
  1643.        XtNfont,
  1644.            getFont("-adobe-times-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1645.            WbNitalicFont, 
  1646.            getFont("-adobe-times-medium-i-normal-*-20-*-*-*-*-*-*-*",whtml),
  1647.            WbNboldFont, 
  1648.            getFont("-adobe-times-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1649.        WbNfixedFont, 
  1650.        getFont("-adobe-courier-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1651.        WbNfixedboldFont, 
  1652.            getFont("-adobe-courier-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1653.        WbNfixeditalicFont, 
  1654.        getFont("-adobe-courier-medium-o-normal-*-20-*-*-*-*-*-*-*",whtml),
  1655.        WbNheader1Font, 
  1656.        getFont("-adobe-times-bold-r-normal-*-25-*-*-*-*-*-*-*",whtml),
  1657.        WbNheader2Font, 
  1658.            getFont("-adobe-times-bold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1659.        WbNheader3Font, 
  1660.            getFont("-adobe-times-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1661.            WbNheader4Font, 
  1662.        getFont("-adobe-times-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1663.        WbNheader5Font, 
  1664.            getFont("-adobe-times-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1665.            WbNheader6Font, 
  1666.            getFont("-adobe-times-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1667.        WbNaddressFont, 
  1668.        getFont("-adobe-times-medium-i-normal-*-20-*-*-*-*-*-*-*",whtml),
  1669.        WbNplainFont, 
  1670.        getFont("-adobe-courier-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1671.        WbNplainboldFont, 
  1672.        getFont("-adobe-courier-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1673.        WbNplainitalicFont, 
  1674.        getFont("-adobe-courier-medium-o-normal-*-18-*-*-*-*-*-*-*",whtml),
  1675.        NULL);
  1676.       he->fonts = TIMES;
  1677.       break;
  1678.    case HREGULAR:
  1679.       XtVaSetValues(whtml,
  1680.        XtNfont,
  1681.            getFont("-adobe-helvetica-medium-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1682.            WbNitalicFont, 
  1683.            getFont("-adobe-helvetica-medium-o-normal-*-17-*-*-*-*-*-*-*",whtml),
  1684.            WbNboldFont, 
  1685.            getFont("-adobe-helvetica-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1686.        WbNfixedFont, 
  1687.            getFont("-adobe-courier-medium-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1688.        WbNfixedboldFont, 
  1689.            getFont("-adobe-courier-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1690.        WbNfixeditalicFont, 
  1691.        getFont("-adobe-courier-medium-o-normal-*-17-*-*-*-*-*-*-*",whtml),
  1692.        WbNheader1Font, 
  1693.        getFont("-adobe-helvetica-bold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1694.        WbNheader2Font, 
  1695.            getFont("-adobe-helvetica-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1696.        WbNheader3Font, 
  1697.            getFont("-adobe-helvetica-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1698.            WbNheader4Font, 
  1699.        getFont("-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1700.        WbNheader5Font, 
  1701.            getFont("-adobe-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1702.            WbNheader6Font, 
  1703.            getFont("-adobe-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1704.        WbNaddressFont, 
  1705.        getFont("-adobe-helvetica-medium-o-normal-*-17-*-*-*-*-*-*-*",whtml),
  1706.        WbNplainFont, 
  1707.        getFont("-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1708.        WbNplainboldFont, 
  1709.        getFont("-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1710.        WbNplainitalicFont, 
  1711.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1712.        NULL);
  1713.       he->fonts = HELVETICA;
  1714.       break;
  1715.    case HSMALL:
  1716.       XtVaSetValues(whtml,
  1717.        XtNfont,
  1718.            getFont("-adobe-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1719.            WbNitalicFont, 
  1720.            getFont("-adobe-helvetica-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1721.            WbNboldFont, 
  1722.            getFont("-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1723.        WbNfixedFont, 
  1724.            getFont("-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1725.        WbNfixedboldFont, 
  1726.            getFont("-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1727.        WbNfixeditalicFont, 
  1728.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1729.        WbNheader1Font, 
  1730.        getFont("-adobe-helvetica-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1731.        WbNheader2Font, 
  1732.            getFont("-adobe-helvetica-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1733.        WbNheader3Font, 
  1734.            getFont("-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1735.            WbNheader4Font, 
  1736.        getFont("-adobe-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1737.        WbNheader5Font, 
  1738.            getFont("-adobe-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1739.            WbNheader6Font, 
  1740.            getFont("-adobe-helvetica-bold-r-normal-*-8-*-*-*-*-*-*-*",whtml),
  1741.        WbNaddressFont, 
  1742.        getFont("-adobe-helvetica-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1743.        WbNplainFont, 
  1744.        getFont("-adobe-courier-medium-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1745.        WbNplainboldFont, 
  1746.        getFont("-adobe-courier-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1747.        WbNplainitalicFont, 
  1748.        getFont("-adobe-courier-medium-o-normal-*-12-*-*-*-*-*-*-*",whtml),
  1749.        NULL);
  1750.       he->fonts = HELVETICA;
  1751.       break;
  1752.    case HLARGE:
  1753.       XtVaSetValues(whtml,
  1754.        XtNfont,
  1755.            getFont("-adobe-helvetica-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1756.            WbNitalicFont, 
  1757.            getFont("-adobe-helvetica-medium-o-normal-*-20-*-*-*-*-*-*-*",whtml),
  1758.            WbNboldFont, 
  1759.            getFont("-adobe-helvetica-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1760.        WbNfixedFont, 
  1761.            getFont("-adobe-courier-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1762.        WbNfixedboldFont, 
  1763.            getFont("-adobe-courier-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1764.        WbNfixeditalicFont, 
  1765.        getFont("-adobe-courier-medium-o-normal-*-20-*-*-*-*-*-*-*",whtml),
  1766.        WbNheader1Font, 
  1767.        getFont("-adobe-helvetica-bold-r-normal-*-25-*-*-*-*-*-*-*",whtml),
  1768.        WbNheader2Font, 
  1769.            getFont("-adobe-helvetica-bold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1770.        WbNheader3Font, 
  1771.            getFont("-adobe-helvetica-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1772.            WbNheader4Font, 
  1773.        getFont("-adobe-helvetica-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1774.        WbNheader5Font, 
  1775.            getFont("-adobe-helvetica-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1776.            WbNheader6Font, 
  1777.            getFont("-adobe-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1778.        WbNaddressFont, 
  1779.        getFont("-adobe-helvetica-medium-o-normal-*-20-*-*-*-*-*-*-*",whtml),
  1780.        WbNplainFont, 
  1781.        getFont("-adobe-courier-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1782.        WbNplainboldFont, 
  1783.        getFont("-adobe-courier-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1784.        WbNplainitalicFont, 
  1785.        getFont("-adobe-courier-medium-o-normal-*-18-*-*-*-*-*-*-*",whtml),
  1786.        NULL);
  1787.       he->fonts = HELVETICA;
  1788.       break;
  1789.    case NCREGULAR:
  1790.       XtVaSetValues(whtml,
  1791.        XtNfont,
  1792.            getFont("-adobe-new century schoolbook-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1793.            WbNitalicFont, 
  1794.            getFont("-adobe-new century schoolbook-medium-i-normal-*-18-*-*-*-*-*-*-*",whtml),
  1795.            WbNboldFont, 
  1796.            getFont("-adobe-new century schoolbook-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1797.        WbNfixedFont, 
  1798.            getFont("-adobe-courier-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1799.        WbNfixedboldFont, 
  1800.            getFont("-adobe-courier-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1801.        WbNfixeditalicFont, 
  1802.        getFont("-adobe-courier-medium-o-normal-*-18-*-*-*-*-*-*-*",whtml),
  1803.        WbNheader1Font, 
  1804.        getFont("-adobe-new century schoolbook-bold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1805.        WbNheader2Font, 
  1806.            getFont("-adobe-new century schoolbook-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1807.        WbNheader3Font, 
  1808.            getFont("-adobe-new century schoolbook-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1809.            WbNheader4Font, 
  1810.        getFont("-adobe-new century schoolbook-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1811.        WbNheader5Font, 
  1812.            getFont("-adobe-new century schoolbook-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1813.            WbNheader6Font, 
  1814.            getFont("-adobe-new century schoolbook-bold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1815.        WbNaddressFont, 
  1816.        getFont("-adobe-new century schoolbook-medium-i-normal-*-18-*-*-*-*-*-*-*",whtml),
  1817.        WbNplainFont, 
  1818.        getFont("-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1819.        WbNplainboldFont, 
  1820.        getFont("-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1821.        WbNplainitalicFont, 
  1822.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1823.        NULL);
  1824.       he->fonts = NEW_CENTURY;
  1825.       break;
  1826.    case NCSMALL:
  1827.       XtVaSetValues(whtml,
  1828.        XtNfont,
  1829.            getFont("-adobe-new century schoolbook-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1830.            WbNitalicFont, 
  1831.            getFont("-adobe-new century schoolbook-medium-i-normal-*-14-*-*-*-*-*-*-*",whtml),
  1832.            WbNboldFont, 
  1833.            getFont("-adobe-new century schoolbook-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1834.        WbNfixedFont, 
  1835.            getFont("-adobe-courier-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1836.        WbNfixedboldFont, 
  1837.            getFont("-adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1838.        WbNfixeditalicFont, 
  1839.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1840.        WbNheader1Font, 
  1841.        getFont("-adobe-new century schoolbook-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1842.        WbNheader2Font, 
  1843.            getFont("-adobe-new century schoolbook-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1844.        WbNheader3Font, 
  1845.            getFont("-adobe-new century schoolbook-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1846.            WbNheader4Font, 
  1847.        getFont("-adobe-new century schoolbook-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1848.        WbNheader5Font, 
  1849.            getFont("-adobe-new century schoolbook-bold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1850.            WbNheader6Font, 
  1851.            getFont("-adobe-new century schoolbook-bold-r-normal-*-8-*-*-*-*-*-*-*",whtml),
  1852.        WbNaddressFont, 
  1853.        getFont("-adobe-new century schoolbook-medium-i-normal-*-14-*-*-*-*-*-*-*",whtml),
  1854.        WbNplainFont, 
  1855.        getFont("-adobe-courier-medium-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1856.        WbNplainboldFont, 
  1857.        getFont("-adobe-courier-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1858.        WbNplainitalicFont, 
  1859.        getFont("-adobe-courier-medium-o-normal-*-12-*-*-*-*-*-*-*",whtml),
  1860.        NULL);
  1861.       he->fonts = NEW_CENTURY;
  1862.       break;
  1863.    case NCLARGE:
  1864.       XtVaSetValues(whtml,
  1865.        XtNfont,
  1866.            getFont("-adobe-new century schoolbook-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1867.            WbNitalicFont, 
  1868.            getFont("-adobe-new century schoolbook-medium-i-normal-*-20-*-*-*-*-*-*-*",whtml),
  1869.            WbNboldFont, 
  1870.            getFont("-adobe-new century schoolbook-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1871.        WbNfixedFont, 
  1872.            getFont("-adobe-courier-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1873.        WbNfixedboldFont, 
  1874.            getFont("-adobe-courier-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1875.        WbNfixeditalicFont, 
  1876.        getFont("-adobe-courier-medium-o-normal-*-20-*-*-*-*-*-*-*",whtml),
  1877.        WbNheader1Font, 
  1878.        getFont("-adobe-new century schoolbook-bold-r-normal-*-25-*-*-*-*-*-*-*",whtml),
  1879.        WbNheader2Font, 
  1880.            getFont("-adobe-new century schoolbook-bold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1881.        WbNheader3Font, 
  1882.            getFont("-adobe-new century schoolbook-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1883.            WbNheader4Font, 
  1884.        getFont("-adobe-new century schoolbook-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1885.        WbNheader5Font, 
  1886.            getFont("-adobe-new century schoolbook-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1887.            WbNheader6Font, 
  1888.            getFont("-adobe-new century schoolbook-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1889.        WbNaddressFont, 
  1890.        getFont("-adobe-new century schoolbook-medium-i-normal-*-20-*-*-*-*-*-*-*",whtml),
  1891.        WbNplainFont, 
  1892.        getFont("-adobe-courier-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1893.        WbNplainboldFont, 
  1894.        getFont("-adobe-courier-bold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1895.        WbNplainitalicFont, 
  1896.        getFont("-adobe-courier-medium-o-normal-*-18-*-*-*-*-*-*-*",whtml),
  1897.        NULL);
  1898.       he->fonts = NEW_CENTURY;
  1899.       break;
  1900.    case LREGULAR:
  1901.       XtVaSetValues(whtml,
  1902.        XtNfont,
  1903.            getFont("-b&h-lucidabright-medium-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1904.            WbNitalicFont, 
  1905.            getFont("-b&h-lucidabright-medium-i-normal-*-17-*-*-*-*-*-*-*",whtml),
  1906.            WbNboldFont, 
  1907.            getFont("-b&h-lucidabright-demibold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1908.        WbNfixedFont, 
  1909.            getFont("-b&h-lucidatypewriter-medium-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1910.        WbNfixedboldFont, 
  1911.            getFont("-b&h-lucidatypewriter-bold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1912.        WbNfixeditalicFont, 
  1913.        getFont("-adobe-courier-medium-o-normal-*-18-*-*-*-*-*-*-*",whtml),
  1914.        WbNheader1Font, 
  1915.        getFont("-b&h-lucidabright-demibold-r-normal-*-24-*-*-*-*-*-*-*",whtml),
  1916.        WbNheader2Font, 
  1917.            getFont("-b&h-lucidabright-demibold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1918.        WbNheader3Font, 
  1919.            getFont("-b&h-lucidabright-demibold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1920.            WbNheader4Font, 
  1921.        getFont("-b&h-lucidabright-demibold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1922.        WbNheader5Font, 
  1923.            getFont("-b&h-lucidabright-demibold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1924.            WbNheader6Font, 
  1925.            getFont("-b&h-lucidabright-demibold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1926.        WbNaddressFont, 
  1927.        getFont("-b&h-lucidabright-medium-i-normal-*-17-*-*-*-*-*-*-*",whtml),
  1928.        WbNplainFont, 
  1929.        getFont("-b&h-lucidatypewriter-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1930.        WbNplainboldFont, 
  1931.        getFont("-b&h-lucidatypewriter-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1932.        WbNplainitalicFont, 
  1933.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1934.        NULL);
  1935.       he->fonts = LUCIDA_BRIGHT;
  1936.       break;
  1937.    case LSMALL:
  1938.       XtVaSetValues(whtml,
  1939.        XtNfont,
  1940.            getFont("-b&h-lucidabright-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1941.            WbNitalicFont, 
  1942.            getFont("-b&h-lucidabright-medium-i-normal-*-14-*-*-*-*-*-*-*",whtml),
  1943.            WbNboldFont, 
  1944.            getFont("-b&h-lucidabright-demibold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1945.        WbNfixedFont, 
  1946.            getFont("-b&h-lucidatypewriter-medium-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1947.        WbNfixedboldFont, 
  1948.            getFont("-b&h-lucidatypewriter-bold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1949.        WbNfixeditalicFont, 
  1950.        getFont("-adobe-courier-medium-o-normal-*-14-*-*-*-*-*-*-*",whtml),
  1951.        WbNheader1Font, 
  1952.        getFont("-b&h-lucidabright-demibold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1953.        WbNheader2Font, 
  1954.            getFont("-b&h-lucidabright-demibold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1955.        WbNheader3Font, 
  1956.            getFont("-b&h-lucidabright-demibold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  1957.            WbNheader4Font, 
  1958.        getFont("-b&h-lucidabright-demibold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1959.        WbNheader5Font, 
  1960.            getFont("-b&h-lucidabright-demibold-r-normal-*-11-*-*-*-*-*-*-*",whtml),
  1961.            WbNheader6Font, 
  1962.            getFont("-b&h-lucidabright-demibold-r-normal-*-10-*-*-*-*-*-*-*",whtml),
  1963.        WbNaddressFont, 
  1964.        getFont("-b&h-lucidabright-medium-i-normal-*-14-*-*-*-*-*-*-*",whtml),
  1965.        WbNplainFont, 
  1966.        getFont("-b&h-lucidatypewriter-medium-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1967.        WbNplainboldFont, 
  1968.        getFont("-b&h-lucidatypewriter-bold-r-normal-*-12-*-*-*-*-*-*-*",whtml),
  1969.        WbNplainitalicFont, 
  1970.        getFont("-adobe-courier-medium-o-normal-*-12-*-*-*-*-*-*-*",whtml),
  1971.        NULL);
  1972.       he->fonts = LUCIDA_BRIGHT;
  1973.       break;
  1974.    case LLARGE:
  1975.       XtVaSetValues(whtml,
  1976.        XtNfont,
  1977.            getFont("-b&h-lucidabright-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1978.            WbNitalicFont, 
  1979.            getFont("-b&h-lucidabright-medium-i-normal-*-20-*-*-*-*-*-*-*",whtml),
  1980.            WbNboldFont, 
  1981.            getFont("-b&h-lucidabright-demibold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1982.        WbNfixedFont, 
  1983.            getFont("-b&h-lucidatypewriter-medium-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1984.        WbNfixedboldFont, 
  1985.            getFont("-b&h-lucidatypewriter-bold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1986.        WbNfixeditalicFont, 
  1987.        getFont("-adobe-courier-medium-o-normal-*-20-*-*-*-*-*-*-*",whtml),
  1988.        WbNheader1Font, 
  1989.        getFont("-b&h-lucidabright-demibold-r-normal-*-25-*-*-*-*-*-*-*",whtml),
  1990.        WbNheader2Font, 
  1991.            getFont("-b&h-lucidabright-demibold-r-normal-*-25-*-*-*-*-*-*-*",whtml),
  1992.        WbNheader3Font, 
  1993.            getFont("-b&h-lucidabright-demibold-r-normal-*-20-*-*-*-*-*-*-*",whtml),
  1994.            WbNheader4Font, 
  1995.        getFont("-b&h-lucidabright-demibold-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  1996.        WbNheader5Font, 
  1997.            getFont("-b&h-lucidabright-demibold-r-normal-*-17-*-*-*-*-*-*-*",whtml),
  1998.            WbNheader6Font, 
  1999.            getFont("-b&h-lucidabright-demibold-r-normal-*-14-*-*-*-*-*-*-*",whtml),
  2000.        WbNaddressFont, 
  2001.        getFont("-b&h-lucidabright-medium-i-normal-*-20-*-*-*-*-*-*-*",whtml),
  2002.        WbNplainFont, 
  2003.        getFont("-b&h-lucidatypewriter-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  2004.        WbNplainboldFont, 
  2005.        getFont("-b&h-lucidatypewriter-medium-r-normal-*-18-*-*-*-*-*-*-*",whtml),
  2006.        WbNplainitalicFont, 
  2007.        getFont("-adobe-courier-medium-o-normal-*-18-*-*-*-*-*-*-*",whtml),
  2008.        NULL);
  2009.       he->fonts = LUCIDA_BRIGHT;
  2010.       break;
  2011.    }
  2012. }
  2013.  
  2014. long getFont (char *name,Widget whtml)
  2015. {
  2016.   XFontStruct *font = XLoadQueryFont (XtDisplay(whtml), name);
  2017.   if (font == NULL)
  2018.     {
  2019.       fprintf (stderr, "Could not open font '%s'\n", name);
  2020.       font = XLoadQueryFont (XtDisplay(whtml), "fixed");
  2021.     }
  2022.   return ((long)font);
  2023. }
  2024.